package com.zzptc.gyc.gfc;
import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;

public class FiestFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_fiest, container, false);
        LineChart lineChart=view.findViewById(R.id.line_Chart);
        ArrayList<Entry> list=new ArrayList<>();
        list.add(new Entry(1,2));
        list.add(new Entry(2,3));
        list.add(new Entry(3,8));
        list.add(new Entry(4,0));
        list.add(new Entry(5,1));
        ArrayList<Entry>listl=new ArrayList<>();
        listl.add(new Entry(1,8));
        listl.add(new Entry(2,6));
        listl.add(new Entry(3,7));
        listl.add(new Entry(4,8));
        listl.add(new Entry(5,3));
        //两个参数
        LineDataSet lineDataSet=new LineDataSet(list,"");
        LineDataSet lineDataSet1=new LineDataSet(listl,"");
        //标点颜色
        lineDataSet.setCircleColor(Color.BLUE);
        //设置线的颜色
        lineDataSet1.setColor(Color.RED);
        //线宽
        lineDataSet.setLineWidth(2f);
        //将两条数据放入集合
        ArrayList<ILineDataSet>lineDataSets=new ArrayList<>();
        lineDataSets.add(lineDataSet);
        lineDataSets.add(lineDataSet1);
        LineData lineData=new LineData(lineDataSets);
        lineChart.setData(lineData);
        XAxis xAxis=lineChart.getXAxis();//设置X轴的值
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setAxisMaximum(5);//最大值
        xAxis.setAxisMinimum(1);//最小值
        xAxis.setLabelCount(5);//数量
        return  view;
    }
}